package edu.washington.ling.syntric.struct.rule;

public class BiRule implements Comparable<BiRule>{
	private BiDSPattern dsPattern;
	private BiPSPattern psPattern;
	
	public BiRule(BiDSPattern dsPatt, BiPSPattern psPatt) {
		dsPattern = dsPatt;
		psPattern = psPatt;
	}
	public BiDSPattern getDSPattern() {
		return dsPattern;
	}
	public BiPSPattern getPSPattern() {
		return psPattern;
	}

	public boolean equals(Object other){
		if (this == other){
			return true;
		}
		if (!(other instanceof BiRule)) {
			return false;
		}
		BiRule otherRule = (BiRule) other;
		return (psPattern.equals(otherRule.psPattern) && dsPattern.equals(otherRule.dsPattern));
	}
	public int hashCode() {
		return dsPattern.hashCode() + 31*psPattern.hashCode();
	}
	@Override
	public int compareTo(BiRule otherRule) {
		int dsPattCmp = dsPattern.compareTo(otherRule.dsPattern);
		return (dsPattCmp != 0 ? dsPattCmp :
				psPattern.compareTo(otherRule.psPattern));
	}
}
